
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
null</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?key=67f19b2653d068ffd5fd2bf6ddd1149d&v=1.2&services=true">
</script>
</head>
<body>
<input type="hidden" id="addr0">
<input type="hidden" id="addr1">
<input type="hidden" id="addr2">
<input type="hidden" id="addr3">
<input type="hidden" id="addr4">
<input type="hidden" id="addr5">
<input type="hidden" id="addr6">
<input type="hidden" id="addr7">
<input type="hidden" id="addr8">
<input type="hidden" id="addr9">
<div style="width:100%;height:100%;" id="container">
</div>
<div id="log" style="font-size:13px;margin-top:0px;display:none;">
</div>
</body>
</html>
<script type="text/javascript">

var city = window.qml.city;
var map = new BMap.Map("container");
// map.setCurrentCity("广州市");
// map.centerAndZoom(new BMap.Point(113.32, 23.15), 13);
//map.setCurrentCity("北京市");
//map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
map.setCurrentCity(city);
map.centerAndZoom(city);

var myGeo = new BMap.Geocoder();

var options = { 
  renderOptions: {map: map,autoViewport: true},
  onSearchComplete: function(results){
    if (driving.getStatus() == BMAP_STATUS_SUCCESS){
      // 获取第一条方案
      var plan = results.getPlan(0);

      //for (i = 0; i < plan.getNumLines(); i ++){
	//  var line = plan.getLine(i);
	//  map.addOverlay(new BMap.Polyline(line.getPoints()));
      //}

      // 获取方案的驾车线路
      var route = plan.getRoute(0);

      // 获取每个关键步骤,并输出到页面
      var s = [];
      for (var i = 0; i < route.getNumSteps(); i ++){
        var step = route.getStep(i);
        s.push((i + 1) + ". " + step.getDescription());
      }
      document.getElementById("log").innerHTML = s.join("<br/>");

///////////////////////////////
      window.qml.route = document.getElementById("log").innerHTML;
      window.qml.showroute();
    }
  }
};
var driving = new BMap.DrivingRoute(map, options);
//driving.search("中关村", "天安门");


var options = {
  onSearchComplete: function(results){
    if (local.getStatus() == BMAP_STATUS_SUCCESS){
      // 判断状态是否正确
      //var s = [];
      for (var i = 0; i < results.getCurrentNumPois(); i ++){
	document.getElementById("addr" + i).value = (results.getPoi(i).title + ", " + results.getPoi(i).address);
	//window.qml.addr.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
        //s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
      }
      //document.getElementById("log").innerHTML = s.join("<br/>");

      window.qml.addr0 = document.getElementById("addr0").value;
      window.qml.addr1 = document.getElementById("addr1").value;
      window.qml.addr2 = document.getElementById("addr2").value;
      window.qml.addr3 = document.getElementById("addr3").value;
      window.qml.addr4 = document.getElementById("addr4").value;
      window.qml.addr5 = document.getElementById("addr5").value;
      window.qml.addr6 = document.getElementById("addr6").value;
      window.qml.addr7 = document.getElementById("addr7").value;
      window.qml.addr8 = document.getElementById("addr8").value;
      window.qml.addr9 = document.getElementById("addr9").value;

      window.qml.qmlCall();

    }
  }
};
var local = new BMap.LocalSearch(map, options);

</script>